package com.asdf.db;

import java.util.ArrayList;
import java.util.List;

import com.asdf.db.operations.IDBOperation;
import com.asdf.db.results.IDBResult;
import com.asdf.entities.Airport;
import com.asdf.entities.CompanyClub;
import com.asdf.external.DBUsageDetails;
import com.asdf.external.DBUserDetails;

/**
 * @author sizzyyy
 *
 */
public class DataBase
{
	public enum DataSource
	{
		UserList, CompanyClubs, AirportList, StatList;
	}
	
	private static DataBase				instance		= new DataBase( );
	private List<CompanyClub>			companyList		= new ArrayList<CompanyClub>( );
	private List<DBUserDetails>			usersList		= new ArrayList<DBUserDetails>( );
	private List<Airport>				airportsList	= new ArrayList<Airport>( );
	private List<DBUsageDetails>		statList		= new ArrayList<DBUsageDetails>( );
	
	private DataBase( )
	{
	}
	
	public static DataBase getInstance( )
	{
		return instance;
	}
	
	public List< ?> getDataSource( DataSource source)
	{
		switch( source)
		{
			case UserList:
						return usersList;
			case CompanyClubs:
						return companyList;
			case AirportList:
						return airportsList;
			case StatList:
						return statList;
		}
		return null;
	}
	
	public IDBResult Do( IDBOperation< ?> operation)
	{
		return operation.perform( );
	}
	
	/** reset database (for testing purposes) */
	public static void resetInstance()
	{
		instance = new DataBase();
	}
}
